home *** CD-ROM | disk | FTP | other *** search
/ mail.altrad.com / 2015.02.mail.altrad.com.tar / mail.altrad.com / TEST / office german / PROPLUS.WW / PROPLSWW.CAB / msjet.xsl.5DF9D670_534C_4AB2_B0C6_FF0B0C448C29 < prev    next >
Extensible Markup Language  |  2006-10-26  |  28KB  |  672 lines

  1. <?xml version="1.0"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" version="1.0" xmlns:mssqlcrt="urn:sql-microsoft-com:sqlcrt" xmlns:mssqldbg="urn:sql-microsoft-com:sqldbg">
  3.     <xsl:output method="xml" indent="yes"/>
  4.  
  5.     <!-- This ALWAYS GENERATED file contains the definitions for the cartridges
  6.                  Microsoft Cartridge Interfaces (Analysis Services 2005)
  7.                  (C) Copyright 1988 - 2003 By Microsoft Corporation.      -->
  8.  
  9.     <!-- Microsoft Jet (Access DB) pluggable cartridge                    -->
  10.  
  11.     <!-- Area of STANDARD parametrizations: these are externally passed   -->
  12.     <xsl:param name="in_CanUseParams">yes</xsl:param>
  13.     <xsl:param name="in_IdentStartQuotingCharacter">[</xsl:param>
  14.     <xsl:param name="in_IdentEndQuotingCharacter">]</xsl:param>
  15.     <xsl:param name="in_StringStartQuotingCharacter">'</xsl:param>
  16.     <xsl:param name="in_StringEndQuotingCharacter">'</xsl:param>
  17.     <xsl:param name="in_IdentInvalidCharacters">[].!</xsl:param>
  18.     
  19.     <!-- Area of CORE parametrizations: These are externally checked      -->
  20.     <mssqlcrt:provider type="prefix">MS Jet</mssqlcrt:provider>
  21.     <mssqlcrt:provider type="prefix">ACCESS</mssqlcrt:provider>
  22.  
  23.     <!-- todo: add time support -->
  24.     <mssqlcrt:capabilities>
  25.         <mssqlcrt:supports-update/>
  26.         <mssqlcrt:supports-insert/>
  27.         <mssqlcrt:supports-subselect/>
  28.         <mssqlcrt:supports-table-alias/>
  29.         <mssqlcrt:supports-column-alias/>
  30.         <mssqlcrt:supports-union/>
  31.         <mssqlcrt:supports-union-all/>
  32.         
  33.         <mssqlcrt:limit-max-connections-count>4</mssqlcrt:limit-max-connections-count>
  34.         
  35.         <mssqlcrt:remote-connection-string-translation-behavior>1</mssqlcrt:remote-connection-string-translation-behavior>
  36.  
  37.         <!-- Map from MSDAInitialize connection string to SQLOLEDB connection string -->
  38.         <mssqlcrt:remote-connection-string-mappings>
  39.             <mssqlcrt:remote-connection-string-mapping>
  40.                 <mssqlcrt:datasource-property>Provider</mssqlcrt:datasource-property>
  41.                 <mssqlcrt:remote-property></mssqlcrt:remote-property>
  42.             </mssqlcrt:remote-connection-string-mapping>
  43.             <mssqlcrt:remote-connection-string-mapping>
  44.                 <mssqlcrt:datasource-property>Data Source</mssqlcrt:datasource-property>
  45.                 <mssqlcrt:remote-property>Database</mssqlcrt:remote-property>
  46.             </mssqlcrt:remote-connection-string-mapping>
  47.             <mssqlcrt:remote-connection-string-mapping>
  48.                 <mssqlcrt:datasource-property>Initial Catalog</mssqlcrt:datasource-property>
  49.                 <mssqlcrt:remote-property></mssqlcrt:remote-property>
  50.             </mssqlcrt:remote-connection-string-mapping>
  51.             <mssqlcrt:remote-connection-string-mapping>
  52.                 <mssqlcrt:datasource-property>User ID</mssqlcrt:datasource-property>
  53.                 <mssqlcrt:remote-property>UID</mssqlcrt:remote-property>
  54.             </mssqlcrt:remote-connection-string-mapping>
  55.             <mssqlcrt:remote-connection-string-mapping>
  56.                 <mssqlcrt:datasource-property>Password</mssqlcrt:datasource-property>
  57.                 <mssqlcrt:remote-property>PWD</mssqlcrt:remote-property>
  58.             </mssqlcrt:remote-connection-string-mapping>
  59.             <mssqlcrt:remote-connection-string-mapping>
  60.                 <mssqlcrt:datasource-property>Persist Security Info</mssqlcrt:datasource-property>
  61.                 <mssqlcrt:remote-property></mssqlcrt:remote-property>
  62.             </mssqlcrt:remote-connection-string-mapping>
  63.         </mssqlcrt:remote-connection-string-mappings>
  64.     </mssqlcrt:capabilities>
  65.  
  66.     <mssqlcrt:schema-classes>
  67.         <mssqlcrt:schema-class>
  68.             <mssqlcrt:managed-provider>System.Data.OleDb</mssqlcrt:managed-provider>
  69.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OleDbSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  70.             <mssqlcrt:query-designer>
  71.                 <mssqlcrt:type>Microsoft.DataWarehouse.Controls.OleDbQueryDesigner, Microsoft.DataWarehouse</mssqlcrt:type>
  72.             </mssqlcrt:query-designer>
  73.         </mssqlcrt:schema-class>
  74.         <mssqlcrt:schema-class>
  75.             <mssqlcrt:managed-provider>System.Data.Odbc</mssqlcrt:managed-provider>
  76.             <mssqlcrt:type>Microsoft.DataWarehouse.Design.OdbcSchema, Microsoft.DataWarehouse</mssqlcrt:type>
  77.         </mssqlcrt:schema-class>
  78.     </mssqlcrt:schema-classes>
  79.  
  80.     <!-- Area of internal parametrizations                                -->
  81.     <!-- overrideOfUseParams:
  82.              yes      = use always parametric queries
  83.              no       = never use parametric queries
  84.              nosubsel = use as yes, but not on subselects
  85.              auto     = use the value of in_CanUseParams to determine     -->
  86.     <xsl:variable name="overrideOfUseParams">auto</xsl:variable>
  87.     <!-- shouldProduceDebug:
  88.              yes      = produce debug information
  89.              no       = do not produce debug information                  -->
  90.     <xsl:variable name="shouldProduceDebug">yes</xsl:variable>
  91.  
  92.     <!-- Area of global variables initializations                         -->
  93.     <xsl:variable name="UseParams">
  94.         <xsl:choose>
  95.             <xsl:when test="normalize-space($overrideOfUseParams) = 'yes' or (normalize-space($overrideOfUseParams) = 'auto' and normalize-space($in_CanUseParams)='yes')">yes</xsl:when>
  96.             <xsl:when test="normalize-space($overrideOfUseParams) = 'nosubsel'">nosubsel</xsl:when>
  97.             <xsl:otherwise>no</xsl:otherwise>
  98.         </xsl:choose>
  99.     </xsl:variable>
  100.     <xsl:variable name="ProduceDebug" select="$shouldProduceDebug"/>
  101.     <xsl:variable name="IdentifierStartQuotingCharacter" select="normalize-space($in_IdentStartQuotingCharacter)"/>
  102.     <xsl:variable name="IdentifierEndQuotingCharacter" select="normalize-space($in_IdentEndQuotingCharacter)"/>
  103.     <xsl:variable name="StringStartQuotingCharacter" select="normalize-space($in_StringStartQuotingCharacter)"/>
  104.     <xsl:variable name="StringEndQuotingCharacter" select="normalize-space($in_StringEndQuotingCharacter)"/>
  105.  
  106.     <!-- Generated statement packaging                                    -->
  107.     <xsl:template match="/">
  108.         <xsl:element name="Statement">
  109.  
  110.             <!-- Generate query                                           -->
  111.             <xsl:element name="Text">
  112.                 <xsl:apply-templates select="./Statement/*[1]"/>
  113.             </xsl:element>
  114.  
  115.             <!-- Generate parameters                                      -->
  116.             <xsl:if test="count(./Statement/Parameters/Parameter)!=0 and ((normalize-space($UseParams)='yes') or (normalize-space($UseParams)='nosubsel'))">
  117.                 <xsl:element name="Parameters">
  118.                     <xsl:choose>
  119.                         <xsl:when test="/Statement/*[1]//Parameter/@ParamName">
  120.                             <xsl:for-each select="./Statement/Parameters/Parameter">
  121.                                 <xsl:element name="Parameter">
  122.                                     <xsl:attribute name="ref">
  123.                                         <xsl:value-of select="./@id"/>
  124.                                     </xsl:attribute>
  125.                                 </xsl:element>
  126.                             </xsl:for-each>
  127.                         </xsl:when>
  128.                         <xsl:otherwise>
  129.                             <xsl:for-each select="./Statement/*[1]//Parameter">
  130.                                 <xsl:element name="Parameter">
  131.                                     <xsl:attribute name="ref">
  132.                                         <xsl:value-of select="./@ref"/>
  133.                                     </xsl:attribute>
  134.                                 </xsl:element>
  135.                             </xsl:for-each>
  136.                         </xsl:otherwise>
  137.                     </xsl:choose>
  138.                 </xsl:element>
  139.             </xsl:if>
  140.  
  141.             <!-- Generate debug info                                      -->
  142.             <xsl:if test="$ProduceDebug='yes'">
  143.                 <xsl:element name="mssqldbg:DebugInfo">
  144.                     <xsl:element name="mssqldbg:GenerateParametricInfo">
  145.                         <xsl:attribute name="mssqldbg:Value">
  146.                             <xsl:value-of select="$UseParams"/>
  147.                         </xsl:attribute>
  148.                         <xsl:element name="mssqldbg:External">
  149.                             <xsl:value-of select="$in_CanUseParams"/>
  150.                         </xsl:element>
  151.                         <xsl:element name="mssqldbg:Internal">
  152.                             <xsl:value-of select="$overrideOfUseParams"/>
  153.                         </xsl:element>
  154.                     </xsl:element>
  155.                 </xsl:element>
  156.             </xsl:if>
  157.  
  158.         </xsl:element>
  159.     </xsl:template>
  160.  
  161.     <!-- Union statement                                                  -->
  162.     <xsl:template match="Union">
  163.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  164.             (
  165.         </xsl:if>
  166.             <xsl:call-template name="print-children-list">
  167.                 <xsl:with-param name="operator" select="' UNION '"/>
  168.             </xsl:call-template>
  169.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  170.             )
  171.         </xsl:if>
  172.     </xsl:template>
  173.  
  174.     <!-- Union All statement                                                  -->
  175.     <xsl:template match="UnionAll">
  176.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  177.             (
  178.         </xsl:if>
  179.             <xsl:call-template name="print-children-list">
  180.                 <xsl:with-param name="operator" select="' UNION ALL '"/>
  181.             </xsl:call-template>
  182.         <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert'">
  183.             )
  184.         </xsl:if>
  185.     </xsl:template>
  186.  
  187.     <!-- Select statement                                                 -->
  188.     <xsl:template match="Select">
  189.         <xsl:choose>
  190.             <xsl:when test="name(./*[1])='ColumnExpressions' and name(./*[1]/*[1])='Count' and name(./*[1]/*[1]/*[1])='Distinct'">
  191.                 SELECT COUNT(*) FROM 
  192.                 ( SELECT <xsl:apply-templates select="./ColumnExpressions/Count/Distinct"/> <xsl:apply-templates select="./*[1]/*[1]/*[2]"/>
  193.                 <xsl:apply-templates select="./Sources"/>
  194.                 <xsl:apply-templates select="./Where"/>
  195.                 <xsl:apply-templates select="./GroupBy"/> )
  196.                 AS [TableAlias]
  197.             </xsl:when>
  198.             <xsl:otherwise>
  199.                 <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert' and name(..) != 'Union' and name(..) != 'UnionAll'">
  200.                     (
  201.                 </xsl:if>
  202.                 SELECT <xsl:apply-templates select="./Distinct"/>
  203.                     <xsl:apply-templates select="./ColumnExpressions"/>
  204.                     <xsl:apply-templates select="./Sources"/>
  205.                     <xsl:apply-templates select="./Where"/>
  206.                     <xsl:apply-templates select="./GroupBy"/>
  207.                     <xsl:apply-templates select="./OrderBy"/>
  208.                 <xsl:if test="name(..) != 'Statement' and name(..) != 'Insert' and name(..) != 'Union' and name(..) != 'UnionAll'">
  209.                     )
  210.                 </xsl:if>
  211.             </xsl:otherwise>
  212.         </xsl:choose>
  213.     </xsl:template>
  214.  
  215.     <!-- Update statement                                                 -->
  216.     <xsl:template match="Update">
  217.         UPDATE <xsl:apply-templates select="./Target"/>
  218.             <xsl:apply-templates select="./Where"/>
  219.     </xsl:template>
  220.  
  221.     <!-- Insert statement                                                 -->
  222.     <xsl:template match="Insert">
  223.         INSERT INTO <xsl:apply-templates select="./Target"/>
  224.         <xsl:apply-templates select="./Select"/>
  225.     </xsl:template>
  226.  
  227.     <!-- Delete statement                                                 -->
  228.     <xsl:template match="Delete">
  229.         DELETE FROM <xsl:apply-templates select="./Target"/>
  230.             <xsl:apply-templates select="./Where"/>
  231.     </xsl:template>
  232.  
  233.     <!-- Drop statement                                                   -->
  234.     <xsl:template match="Drop">
  235.         DROP <xsl:apply-templates select="./*"/>
  236.     </xsl:template>
  237.  
  238.     <!-- Create statement                                                 -->
  239.     <xsl:template match="Create">
  240.         CREATE <xsl:apply-templates select="./*[1]"/>
  241.         <xsl:choose>
  242.             <xsl:when test="name(./*[1]) = 'Table'">( <xsl:apply-templates select="./*[2]"/> )</xsl:when>
  243.         </xsl:choose>
  244.     </xsl:template>
  245.  
  246.     <xsl:template match="Distinct">
  247.         DISTINCT
  248.     </xsl:template>
  249.  
  250.     <xsl:template match="As">
  251.         <xsl:apply-templates select="./*[1]"/> AS <xsl:apply-templates select="./*[2]"/>
  252.     </xsl:template>
  253.  
  254.     <xsl:template match="Sources">
  255.         FROM <xsl:call-template name="print-children-list"/>
  256.     </xsl:template>
  257.  
  258.     <xsl:template match="ColumnDefinitions">
  259.         <xsl:call-template name="print-children-list"/>
  260.     </xsl:template>
  261.  
  262.     <xsl:template match="GroupBy">
  263.         GROUP BY <xsl:call-template name="print-children-list"/>
  264.     </xsl:template>
  265.  
  266.     <xsl:template match="OrderBy">
  267.         ORDER BY <xsl:call-template name="print-children-list"/>
  268.     </xsl:template>
  269.  
  270.     <xsl:template match="Where">
  271.         WHERE <xsl:apply-templates select="./*"/>
  272.     </xsl:template>
  273.  
  274.     <xsl:template match="Having">
  275.         HAVING <xsl:apply-templates select="./*"/>
  276.     </xsl:template>
  277.  
  278.     <xsl:template match="ColumnExpressions">
  279.         <xsl:call-template name="print-children-list"/>
  280.     </xsl:template>
  281.  
  282.     <xsl:template match="ColumnUpdates">
  283.         <xsl:call-template name="print-children-list"/>
  284.     </xsl:template>
  285.  
  286.     <xsl:template match="Assign">
  287.         <xsl:apply-templates select="./*[1]"/>=<xsl:apply-templates select="./*[2]"/>
  288.     </xsl:template>
  289.  
  290.     <xsl:template match="Insert/Target">
  291.         <xsl:apply-templates select="./Table"/>
  292.         (
  293.             <xsl:call-template name="print-list">
  294.                 <xsl:with-param name="value-node" select="./ColumnUpdates/*/*[1]"/>
  295.             </xsl:call-template>
  296.         )
  297.         <xsl:if test="./*[2]/Assign">
  298.             VALUES
  299.             (
  300.                 <xsl:call-template name="print-list">
  301.                     <xsl:with-param name="value-node" select="./ColumnUpdates/*/*[2]"/>
  302.                 </xsl:call-template>
  303.             )
  304.         </xsl:if>
  305.     </xsl:template>
  306.  
  307.     <xsl:template match="Update/Target">
  308.         <xsl:apply-templates select="./Table"/>
  309.         SET <xsl:apply-templates select="./ColumnUpdates"/>
  310.     </xsl:template>
  311.  
  312.     <xsl:template match="Delete/Target">
  313.         <xsl:apply-templates select="./Table"/>
  314.     </xsl:template>
  315.  
  316.     <xsl:template match="Insert/Target/ColumnUpdates/Assign/SQLColumn[1]">
  317.         <!-- The table name is not printed for LHS of assignments in insert -->
  318.         <xsl:apply-templates select="./Column"/>
  319.     </xsl:template>
  320.  
  321.     <xsl:template match="Create/ColumnDefinitions/SQLColumn">
  322.         <xsl:apply-templates select="./Column"/>
  323.         <xsl:apply-templates select="./Type"/>
  324.         <xsl:apply-templates select="./Usage"/>
  325.     </xsl:template>
  326.  
  327.     <xsl:template match="SQLColumn">
  328.         <xsl:variable name="table">
  329.             <xsl:if test="name(..)!='Count' or name(./Column/*[1]) != 'Asterisk'"><xsl:apply-templates select="./Table"/></xsl:if>
  330.         </xsl:variable>
  331.         <xsl:variable name="column">
  332.             <xsl:apply-templates select="./Column"/>
  333.         </xsl:variable>
  334.         <xsl:choose>
  335.             <xsl:when test="$table = ''">
  336.                 <xsl:value-of select="$column"/>
  337.             </xsl:when>
  338.             <xsl:otherwise>
  339.                 <xsl:value-of select="concat($table,'.', $column)"/>
  340.             </xsl:otherwise>
  341.         </xsl:choose>
  342.     </xsl:template>
  343.  
  344.     <xsl:template match="Create/Database|Drop/Database">
  345.         DATABASE <xsl:apply-templates select="./Name"/>
  346.     </xsl:template>
  347.  
  348.     <xsl:template match="Table">
  349.         <xsl:call-template name="build-quoted-schema-object"/>
  350.     </xsl:template>
  351.  
  352.     <xsl:template match="Create/Table|Drop/Table">
  353.         TABLE <xsl:call-template name="build-quoted-schema-object"/>
  354.     </xsl:template>
  355.  
  356.     <xsl:template match="View">
  357.         <xsl:call-template name="build-quoted-schema-object"/>
  358.     </xsl:template>
  359.  
  360.     <xsl:template match="Drop/View">
  361.         VIEW <xsl:call-template name="build-quoted-schema-object"/>
  362.     </xsl:template>
  363.  
  364.     <xsl:template match="Index">
  365.         <xsl:apply-templates select="./Name"/>
  366.     </xsl:template>
  367.  
  368.     <xsl:template match="Drop/Index">
  369.         INDEX <xsl:apply-templates select="./Name"/>
  370.     </xsl:template>
  371.  
  372.     <xsl:template match="Column">
  373.         <xsl:apply-templates select="./Asterisk"/>
  374.         <xsl:apply-templates select="./Name"/>
  375.     </xsl:template>
  376.  
  377.     <xsl:template match="Table/Name|View/Name|Index/Name|Column/Name|Database/Name|Schema">
  378.         <xsl:call-template name="quote-identifier"/>
  379.     </xsl:template>
  380.  
  381.     <xsl:template match="Usage">
  382.         <xsl:variable name="usage"><xsl:value-of select="."/></xsl:variable>
  383.         <xsl:choose>
  384.             <xsl:when test="$usage = 'Key'">    primary key   </xsl:when>
  385.         </xsl:choose>
  386.     </xsl:template>
  387.  
  388.     <xsl:template match="OpaqueExpression">
  389.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  390.             (
  391.         </xsl:if>
  392.         <xsl:value-of select="."/>
  393.         <xsl:if test="name(..) = 'As' and name(../..) = 'Sources'">
  394.             )
  395.         </xsl:if>
  396.     </xsl:template>
  397.  
  398.     <xsl:template match="OrderExpression">
  399.         <xsl:apply-templates select="./*[1]"/>
  400.         <xsl:apply-templates select="./Asc"/>
  401.         <xsl:apply-templates select="./Desc"/>
  402.     </xsl:template>
  403.  
  404.     <xsl:template match="Asc">
  405.         ASC
  406.     </xsl:template>
  407.  
  408.     <xsl:template match="Desc">
  409.         DESC
  410.     </xsl:template>
  411.  
  412.     <!-- Print values: ? for parametric queries and convert expressions
  413.          for non-parametric queries                                       -->
  414.     <xsl:template match="Parameter">
  415.         <xsl:choose>
  416.             <xsl:when test="$UseParams = 'yes' or $UseParams = 'nosubsel'">
  417.                 <xsl:choose>
  418.                     <xsl:when test="./@ParamName">
  419.                         @<xsl:value-of select="./@ParamName"/>
  420.                     </xsl:when>
  421.                     <xsl:otherwise>
  422.                         ?
  423.                     </xsl:otherwise>
  424.                 </xsl:choose>
  425.             </xsl:when>
  426.             <xsl:otherwise>
  427.                 <xsl:call-template name="print-non-parametric-parameter-ref">
  428.                     <xsl:with-param name="parameter-reference" select="."/>
  429.                 </xsl:call-template>
  430.             </xsl:otherwise>
  431.         </xsl:choose>
  432.     </xsl:template>
  433.  
  434.     <!-- Asterisk                                                         -->
  435.     <xsl:template match="Asterisk">*</xsl:template>
  436.  
  437.     <!-- Count/Min/Max/Sum                                                -->
  438.     <xsl:template match="Count|Min|Max|Sum">
  439.         <xsl:variable name="function">
  440.             <xsl:choose>
  441.                 <xsl:when test="name()='Count'"> COUNT </xsl:when>
  442.                 <xsl:when test="name()='Min'"> MIN </xsl:when>
  443.                 <xsl:when test="name()='Max'"> MAX </xsl:when>
  444.                 <xsl:when test="name()='Sum'"> SUM </xsl:when>
  445.             </xsl:choose>
  446.         </xsl:variable>
  447.         <xsl:value-of select="$function"/>( <xsl:apply-templates select="./*[1]"/> )
  448.     </xsl:template>
  449.  
  450.     <!-- Binary expressions                                               -->
  451.     <!-- Equal/NotEqual/Greater/GreaterOrEqual/Less/LessOrEqual/In/And/Or/Plus/Minus/Divide/Multiply
  452.          expressions                                                      -->
  453.     <xsl:template match="Equal|NotEqual|Greater|GreaterOrEqual|Less|LessOrEqual|In|And|Or|Plus|Minus|Divide|Multiply">
  454.         <xsl:variable name="operator">
  455.             <xsl:choose>
  456.                 <xsl:when test="name()='Equal'">            =        </xsl:when>
  457.                 <xsl:when test="name()='NotEqual'">            <>    </xsl:when>
  458.                 <xsl:when test="name()='Greater'">            >        </xsl:when>
  459.                 <xsl:when test="name()='GreaterOrEqual'">    >=        </xsl:when>
  460.                 <xsl:when test="name()='Less'">                <    </xsl:when>
  461.                 <xsl:when test="name()='LessOrEqual'">        <=    </xsl:when>
  462.                 <xsl:when test="name()='In'">                IN        </xsl:when>
  463.                 <xsl:when test="name()='And'">                AND        </xsl:when>
  464.                 <xsl:when test="name()='Or'">                OR        </xsl:when>
  465.                 <xsl:when test="name()='Plus'">                +        </xsl:when>
  466.                 <xsl:when test="name()='Minus'">            -        </xsl:when>
  467.                 <xsl:when test="name()='Divide'">            /        </xsl:when>
  468.                 <xsl:when test="name()='Multiply'">            *        </xsl:when>
  469.             </xsl:choose>
  470.         </xsl:variable>
  471.         (
  472.             <xsl:call-template name="print-children-list">
  473.                 <xsl:with-param name="operator" select="$operator"/>
  474.             </xsl:call-template>
  475.         )
  476.     </xsl:template>
  477.  
  478.     <!-- Postfix unary expressions                                        -->
  479.     <!-- IsNull
  480.          expressions                                                      -->
  481.     <xsl:template match="IsNull">
  482.         <xsl:variable name="operator">
  483.             <xsl:choose>
  484.                 <xsl:when test="name()='IsNull'">            IS NULL        </xsl:when>
  485.             </xsl:choose>
  486.         </xsl:variable>
  487.         (
  488.             <xsl:apply-templates select="./*[1]"/>
  489.             <xsl:value-of select="$operator"/>
  490.         )
  491.     </xsl:template>
  492.  
  493.     <!-- Types                                                            -->
  494.     <xsl:template match="Type">
  495.         <xsl:variable name="type-val"><xsl:value-of select="normalize-space(./text())"/></xsl:variable>
  496.         <xsl:choose>
  497.             <xsl:when test="$type-val = 'DBTYPE_BSTR'">    varchar      </xsl:when>
  498.             <xsl:when test="$type-val = 'DBTYPE_WSTR'">    varchar      </xsl:when>
  499.             <xsl:when test="$type-val = 'DBTYPE_STR'">     varchar      </xsl:when>
  500.             <xsl:when test="$type-val = 'DBTYPE_BOOL'">    bit          </xsl:when>
  501.             <xsl:when test="$type-val = 'DBTYPE_I1'">      tinyint      </xsl:when>
  502.             <xsl:when test="$type-val = 'DBTYPE_I2'">      smallint     </xsl:when>
  503.             <xsl:when test="$type-val = 'DBTYPE_I4'">      int          </xsl:when>
  504.             <xsl:when test="$type-val = 'DBTYPE_I8'">      long         </xsl:when>
  505.             <xsl:when test="$type-val = 'DBTYPE_UI1'">     tinyint      </xsl:when>
  506.             <xsl:when test="$type-val = 'DBTYPE_UI2'">     smallint     </xsl:when>
  507.             <xsl:when test="$type-val = 'DBTYPE_UI4'">     int          </xsl:when>
  508.             <xsl:when test="$type-val = 'DBTYPE_UI8'">     long         </xsl:when>
  509.             <xsl:when test="$type-val = 'DBTYPE_R4'">      float        </xsl:when>
  510.             <xsl:when test="$type-val = 'DBTYPE_R8'">      real         </xsl:when>
  511.             <xsl:when test="$type-val = 'DBTYPE_DATE'">    datetime     </xsl:when>
  512.             <xsl:when test="$type-val = 'DBTYPE_DBTIMESTAMP'">    datetime     </xsl:when>
  513.             <xsl:when test="$type-val = 'DBTYPE_CY'">      money        </xsl:when>
  514.             <xsl:when test="$type-val = 'DBTYPE_VARIANT'"> sql_variant  </xsl:when>
  515.             <xsl:when test="$type-val = 'DBTYPE_GUID'"> guid </xsl:when>
  516.             <xsl:when test="$type-val = 'DBTYPE_ByteArray'"> varbinary  </xsl:when>
  517.             <xsl:when test="$type-val = 'DBTYPE_DECIMAL'"> decimal      </xsl:when>
  518.         </xsl:choose>
  519.         <xsl:apply-templates select="./Size"/>
  520.         <xsl:apply-templates select="./Precision"/>
  521.         <xsl:apply-templates select="./Scale"/>
  522.     </xsl:template>
  523.  
  524.     <!-- Size (optional)                                                  -->
  525.     <xsl:template match="Size">
  526.     ( <xsl:value-of select="./text()"/> )
  527.     </xsl:template>
  528.     
  529.     <!-- Precision (optional)                                                  -->
  530.     <xsl:template match="Precision">
  531.     ( <xsl:value-of select="./text()"/>
  532.     </xsl:template>
  533.  
  534.     <!-- Scale (optional)                                                  -->
  535.     <xsl:template match="Scale">
  536.     , <xsl:value-of select="./text()"/> )
  537.     </xsl:template>    
  538.     <!-- By default don't do anything                                     -->
  539.     <xsl:template match="*">
  540.     </xsl:template>
  541.  
  542.     <!-- Print a schema object                                               -->
  543.     <xsl:template name="build-quoted-schema-object"> 
  544.         <xsl:param name="schema-object-node" select="."/>
  545.  
  546.         <xsl:variable name="schema">
  547.             <xsl:apply-templates select="$schema-object-node/Schema"/>
  548.         </xsl:variable>
  549.         <xsl:variable name="table">
  550.             <xsl:apply-templates select="$schema-object-node/Name"/>
  551.         </xsl:variable>
  552.         <xsl:choose>
  553.             <xsl:when test="$schema = ''">
  554.                 <xsl:value-of select="$table"/>
  555.             </xsl:when>
  556.             <xsl:otherwise>
  557.                 <xsl:value-of select="concat($schema,'.', $table)"/>
  558.             </xsl:otherwise>
  559.         </xsl:choose>
  560.     </xsl:template>
  561.  
  562.     <!-- Convert an identifier to the OLEDB quotation form                -->
  563.     <xsl:template name="quote-identifier"> 
  564.         <xsl:param name="identifier" select="."/>
  565.  
  566.         <xsl:value-of select="$IdentifierStartQuotingCharacter"/>
  567.         <xsl:call-template name="normalize-entity-aux">
  568.             <xsl:with-param name="entity" select="$identifier"/>
  569.             <xsl:with-param name="end-quoting-char" select="$IdentifierEndQuotingCharacter"/>
  570.         </xsl:call-template>
  571.         <xsl:value-of select="$IdentifierEndQuotingCharacter"/>
  572.     </xsl:template>
  573.  
  574.     <!-- Convert a string to the string quotation form                    -->
  575.     <xsl:template name="quote-string"> 
  576.         <xsl:param name="string" select="."/>
  577.  
  578.         <xsl:value-of select="$StringStartQuotingCharacter"/>
  579.         <xsl:call-template name="normalize-entity-aux">
  580.             <xsl:with-param name="entity" select="$string"/>
  581.             <xsl:with-param name="end-quoting-char" select="$StringEndQuotingCharacter"/>
  582.         </xsl:call-template>
  583.         <xsl:value-of select="$StringEndQuotingCharacter"/>
  584.     </xsl:template>
  585.  
  586.     <!-- Convert an entity to the quotation form (recursive, aux)  by
  587.          duplicating the end quoting character                            -->
  588.     <xsl:template name="normalize-entity-aux"> 
  589.         <xsl:param name="entity"/>
  590.         <xsl:param name="end-quoting-char"/>
  591.  
  592.         <xsl:choose>
  593.             <xsl:when test="contains($entity, $end-quoting-char)">
  594.                 <xsl:value-of select="substring-before($entity, $end-quoting-char)"/>
  595.                 <xsl:value-of select="$end-quoting-char"/>
  596.                 <xsl:value-of select="$end-quoting-char"/>
  597.                 <xsl:call-template name="normalize-entity-aux">
  598.                     <xsl:with-param name="entity" select="substring-after($entity, $end-quoting-char)"/>
  599.                     <xsl:with-param name="end-quoting-char" select="$end-quoting-char"/>
  600.                 </xsl:call-template>
  601.             </xsl:when>
  602.             <xsl:otherwise>
  603.                 <xsl:value-of select="$entity"/>
  604.             </xsl:otherwise>
  605.         </xsl:choose>
  606.     </xsl:template>
  607.  
  608.     <!-- Print the children list                                          -->
  609.     <xsl:template name="print-children-list">
  610.         <xsl:param name="operator" select="','"/>
  611.         
  612.         <xsl:call-template name="print-list">
  613.             <xsl:with-param name="value-node" select="./*"/>
  614.             <xsl:with-param name="operator" select="$operator"/>
  615.         </xsl:call-template>
  616.     </xsl:template>
  617.  
  618.     <!-- Print a list                                                     -->
  619.     <xsl:template name="print-list">
  620.         <xsl:param name="operator" select="','"/>
  621.         <xsl:param name="value-node" select="."/>
  622.  
  623.         <xsl:for-each select="$value-node">
  624.             <xsl:apply-templates select="."/>
  625.             <xsl:if test="position()!=last()">
  626.                 <xsl:value-of select="$operator"/>
  627.             </xsl:if>
  628.         </xsl:for-each>
  629.     </xsl:template>
  630.  
  631.     <!-- Get the value of a parameter ref for the query                   -->
  632.     <xsl:template name="print-non-parametric-parameter-ref">
  633.         <xsl:param name="parameter-reference"/>
  634.  
  635.         <xsl:variable name="reference"><xsl:value-of select="$parameter-reference/@ref"/></xsl:variable>
  636.         <xsl:call-template name="print-non-parametric-parameter">
  637.             <xsl:with-param name="parameter" select="/Statement/Parameters/Parameter[@id=$reference]"/>
  638.         </xsl:call-template>
  639.     </xsl:template>
  640.  
  641.     <!-- Get the value of a parameter ref for the query                   -->
  642.     <xsl:template name="print-non-parametric-parameter">
  643.         <xsl:param name="parameter"/>
  644.  
  645.         <xsl:variable name="db-type"><xsl:value-of select="$parameter/@DBTYPE"/></xsl:variable>
  646.         <xsl:variable name="value"><xsl:value-of select="$parameter/text()"/></xsl:variable>
  647.         <xsl:choose>
  648.             <xsl:when test="$db-type = 'DBTYPE_BSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  649.             <xsl:when test="$db-type = 'DBTYPE_WSTR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  650.             <xsl:when test="$db-type = 'DBTYPE_STR'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  651.             <xsl:when test="$db-type = 'DBTYPE_BOOL'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS bit)</xsl:when>
  652.             <xsl:when test="$db-type = 'DBTYPE_I1'"><xsl:value-of select="$value"/></xsl:when>
  653.             <xsl:when test="$db-type = 'DBTYPE_I2'"><xsl:value-of select="$value"/></xsl:when>
  654.             <xsl:when test="$db-type = 'DBTYPE_I4'"><xsl:value-of select="$value"/></xsl:when>
  655.             <xsl:when test="$db-type = 'DBTYPE_I8'"><xsl:value-of select="$value"/></xsl:when>
  656.             <xsl:when test="$db-type = 'DBTYPE_UI1'"><xsl:value-of select="$value"/></xsl:when>
  657.             <xsl:when test="$db-type = 'DBTYPE_UI2'"><xsl:value-of select="$value"/></xsl:when>
  658.             <xsl:when test="$db-type = 'DBTYPE_UI4'"><xsl:value-of select="$value"/></xsl:when>
  659.             <xsl:when test="$db-type = 'DBTYPE_UI8'"><xsl:value-of select="$value"/></xsl:when>
  660.             <xsl:when test="$db-type = 'DBTYPE_R4'"><xsl:value-of select="$value"/></xsl:when>
  661.             <xsl:when test="$db-type = 'DBTYPE_R8'"><xsl:value-of select="$value"/></xsl:when>
  662.             <xsl:when test="$db-type = 'DBTYPE_DATE'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  663.             <xsl:when test="$db-type = 'DBTYPE_DBTIMESTAMP'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS datetime)</xsl:when>
  664.             <xsl:when test="$db-type = 'DBTYPE_CY'">CAST( <xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template> AS money)</xsl:when>
  665.             <xsl:when test="$db-type = 'DBTYPE_VARIANT'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  666.             <xsl:when test="$db-type = 'DBTYPE_GUID'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  667.             <xsl:when test="$db-type = 'DBTYPE_ByteArray'"><xsl:call-template name="quote-string"><xsl:with-param name="string" select="$value"/></xsl:call-template></xsl:when>
  668.             <xsl:when test="$db-type = 'DBTYPE_DECIMAL'"><xsl:value-of select="$value"/></xsl:when>
  669.         </xsl:choose>
  670.     </xsl:template>
  671. </xsl:stylesheet>
  672.